<template>
    <div>   
        <table class="table">
            <tbody class="table">
                <tr>
                    <td>用户名</td>
                    <td>
                        <input type="text" v-model="data.name">
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="data.pwd">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2">
                        <input type="button" value="登录" @click="login">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';


const data=ref({
    name:'',
    pwd:''
})

const router=useRouter();
const login=()=>{
    axios.get("https://localhost:7233/api/House/LoginHouse",{params:data.value}).then(res=>{
        if(res.data.uid==-1){
            alert("用户名不存在")
            return
        }
        if(res.data.uid==-2){
            alert("密码错误");
            return;
        }
        if(res.data.uid>0){
            alert("登陆成功");
            router.push({
                path:'/ShowView'
            })
        }
    })
}

</script>

<style scoped>

</style>